<template>
  <div>
    <div id="nav">
      <router-link to="/" class="tab-bar-item">
        <div class="icon"><i class="iconfont icon-shouye"></i></div>
        <div>首页</div>
      </router-link>
      <router-link to="/category" class="tab-bar-item">
        <div class="icon">
          <i class="iconfont icon-leimupinleifenleileibie"></i>
        </div>
        <div>分类</div>
      </router-link>
      <router-link to="/Shopcart" class="tab-bar-item">
        <div class="icon">
          <van-badge :content="$store.state.cartCount" max="9">
            <i class="iconfont icon-xiazai1"></i>
          </van-badge>
        </div>
        <div>购物车</div>
      </router-link>
      <router-link to="/profile" class="tab-bar-item">
        <div class="icon"><i class="iconfont icon-yonghu"></i></div>
        <div>我的</div>
      </router-link>
    </div>
    <!-- <router-view v-slot="{ Component }">
      <transition>
        <keep-alive>
          <component :is="Component" />
        </keep-alive>
      </transition>
    </router-view> -->
    <router-view />
  </div>
</template>

<script>
import { Mounted, onMounted } from "vue";
import { useStore } from "vuex";
export default {
  setup() {
    const store = useStore();
    onMounted(() => {
      store.dispatch('updataCart');
    });
  },
};
</script>
>

<style lang="scss">
@import "assets/css/base.css";
@import "assets/css/icon/iconfont.css";
#app {
  text-align: center;
  color: #2c3e50;
}

#nav {
  background-color: #f6f6f6;
  display: flex;
  position: fixed;
  left: 0px;
  right: 0px;
  bottom: 0px;
  z-index: 10;

  a {
    color: var(--color-text);

    &.router-link-exact-active {
      color: var(--color-high-text);
    }
  }

  .tab-bar-item {
    flex: 1;
    text-align: center;
    height: 50px;
    font-size: var(--font-size);
  }

  .tab-bar-item .icon {
    width: 24px;
    height: 24px;
    margin-top: 5px;
    vertical-align: middle;
    display: inline-block;
  }
}
</style>
